/*
@Time : 2020/7/15 17:11
@Author : lym
@File : validatorSelf
@Software: GoLand
*/
package validatorUtils

import (
	"gin-YiStudio-V1/common/consts"
	"github.com/astaxie/beego/logs"
	"github.com/go-playground/validator/v10"
	"regexp"
)

/**
 * @Author lym
 * @Description 自定义校验器，校验年龄不能小于18岁
 * @Date 2020-07-15, 星期三 17:02
 * @Param
 * @return
 **/
func MustBig(f1 validator.FieldLevel) bool {
	if f1.Field().Interface().(int) <= 18 {
		return false
	}
	return true
}

func CheckSpecialNum(f1 validator.FieldLevel) bool {
	re := regexp.MustCompile(consts.RE_LOCATION)
	if pair := re.MatchString(f1.Field().Interface().(string)); pair {
		logs.Info("地址包含特殊字符,errorStr={%s}", f1.Field().Interface().(string))
		return false
	}
	return true
}
